
let todos = [];
// chrome 本地存储的 key 为 todos
chrome.storage.local.get('todos', function(result) {
    todos = result.todos || [];
    updateBadge();
});

// 添加更新扩展图标徽章的函数
function updateBadge() {
    if (!chrome.action) return;
    const uncompletedCount = todos.filter(todo => !todo.completed).length;
    // 设置徽章文本
    chrome.action.setBadgeText({
        text: uncompletedCount > 0 ? uncompletedCount.toString() : ''
    });
    // 设置徽章背景色为红色
    chrome.action.setBadgeBackgroundColor({
        color: '#ff4444'
    });
    // 设置徽章文字颜色为白色
    chrome.action.setBadgeTextColor({
        color: '#FFFFFF'
    });
}